package reader;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

public class FileReaderDemo {

	public static void main(String[] args) {
		Reader fr = null;
		try {
			// 创建FileReader对象
			fr = new FileReader("e:/t01/hello.txt");
			// 读取文本文件
			StringBuffer sb = new StringBuffer();
			char[] words = new char[1024];
			while(fr.read(words) != -1){
				sb.append(words);
			}
			System.out.println(sb);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				// 关闭流
				fr.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

	}

}
